<template>
    <div class="JNPF-common-layout">
        <div class="JNPF-common-layout-center">
            <el-row class="JNPF-common-search-box" :gutter="16">
                <el-form @submit.native.prevent>
                    <el-col :span="6">
                        <el-form-item label="合伙人名称">
                            <el-input v-model="query.userName" placeholder="合伙人名称" clearable />
                        </el-form-item>
                    </el-col>

                    <el-col :span="6">
                        <el-form-item>
                            <el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
                            <el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
                        </el-form-item>
                    </el-col>
                </el-form>
            </el-row>
            <div class="JNPF-common-layout-main JNPF-flex-main">
                <div class="JNPF-common-head">
                    <div>
                       
                    </div>
                    <div class="JNPF-common-head-right">
                        <el-tooltip effect="dark" content="刷新" placement="top">
                            <el-link icon="icon-ym icon-ym-Refresh JNPF-common-head-icon" :underline="false"
                                @click="reset()" />
                        </el-tooltip>
                        <screenfull :isContainer="true" />
                        <el-tooltip effect="dark" content="列设置" placement="top">
                            <el-link icon="icon-ym icon-ym-options JNPF-common-head-icon" :underline="false" />
                        </el-tooltip>
                    </div>
                </div>
                <JNPF-table v-loading="listLoading" :data="list">
                    <el-table-column prop="userName" label="用户" align="left"  width="120"/>
                    <el-table-column prop="points" label="积分" align="left"  width="100"/>
                    <el-table-column label="账户" >
                        <template slot-scope="scope">
                            <el-tag v-if="scope.row.payType == 1">
                                {{ '银行卡提现 银行：'+scope.row.payBankName+'姓名'+scope.row.payName+'；账号'+scope.row.payBankNumber}}
                            </el-tag>
                            
                            <el-tag v-if="scope.row.payType == 2">
                                {{ '支付宝提现 姓名：'+scope.row.payName+'；账号'+scope.row.payAccount}}
                            </el-tag>

                        </template>
                    </el-table-column>


                    <el-table-column label="类别" width="100">
                        <template slot-scope="scope">
                            <el-tag v-if="scope.row.type == 0">
                                {{ '待审核' }}
                            </el-tag>
                            <el-tag v-if="scope.row.type == 1">
                                {{ '提现成功' }}
                            </el-tag>
                            <el-tag v-if="scope.row.type == 2">
                                {{ '驳回' }}
                            </el-tag>

                        </template>
                    </el-table-column>
                    <el-table-column prop="remark" label="备注" align="left" />
                    <el-table-column prop="creatorTime" label="创建时间" align="left" width="150" />
                    <el-table-column prop="lastModifyTime" label="审核时间" align="left" width="150" />
                    <el-table-column label="操作" fixed="right" width="100">
                        <template slot-scope="scope" v-if="scope.row.type == 0">
                            <el-button type="text" @click="addOrUpdateHandle(scope.row.id,scope.row)" >
								审核
							</el-button>
						</template>
                    </el-table-column>
                </JNPF-table>
                <pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize"
                    @pagination="initData" />
            </div>
        </div>
        <JNPF-Form v-if="formVisible" ref="JNPFForm" @refresh="refresh" />
        <ExportBox v-if="exportBoxVisible" ref="ExportBox" @download="download" />
    </div>

</template>
<script>
import request from '@/utils/request'
import { getDictionaryDataSelector } from '@/api/systemData/dictionary'
import JNPFForm from './Form'
import ExportBox from './ExportBox'
import { previewDataInterface } from '@/api/systemData/dataInterface'

export default {
    components: { JNPFForm, ExportBox },
    data() {
        return {
            showAll: false,
            query: {
                userId: undefined,
                points: undefined,
                type: undefined,
                remark: undefined,
                sortCode: undefined,

            },
            defaultProps: {
                children: 'children',
                label: 'fullName'
            },
            list: [],
            listLoading: true,
            total: 0,
            listQuery: {
                currentPage: 1,
                pageSize: 20,

                sort: "desc",
                sidx: "",
            },
            formVisible: false,
            exportBoxVisible: false,
            columnList: [
                { prop: 'userId', label: '用户Id' },
                { prop: 'points', label: '积分' },
                { prop: 'type', label: '类别：0 待审核 1 提现成功 2 拒绝' },
                { prop: 'remark', label: '备注' },
                { prop: 'sortCode', label: '排序' },

            ],


        }
    },
    computed: {},
    created() {
        this.initData();


    },
    methods: {


        initData() {
            this.listLoading = true;
            let query = {
                ...this.listQuery,
                ...this.query
            };
            request({
                url: `/api/Jiushi/Pointswithdrawal/GetListAdmin`,
                method: 'get',
                data: query
            }).then(res => {
                this.list = res.data.list
                this.total = res.data.pagination.total
                this.listLoading = false
                this.$nextTick(() => {
                    this.tableHeight = "100%"
                });
            })
        },
        handleDel(id) {
            this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
                type: 'warning'
            }).then(() => {
                request({
                    url: `/api/Jiushi/Pointswithdrawal/${id}`,
                    method: 'DELETE'
                }).then(res => {
                    this.$message({
                        type: 'success',
                        message: res.msg,
                        onClose: () => {
                            this.initData()
                        }
                    });
                })
            }).catch(() => {
            });
        },
        addOrUpdateHandle(id, row) {
            this.formVisible = true
            this.$nextTick(() => {
                this.$refs.JNPFForm.init(id, row)
            })
        },
        exportData() {
            this.exportBoxVisible = true
            this.$nextTick(() => {
                this.$refs.ExportBox.init(this.columnList)
            })
        },
        download(data) {
            let query = { ...data, ...this.listQuery, ...this.query }
            request({
                url: `/api/Jiushi/Pointswithdrawal/Actions/Export`,
                method: 'POST',
                data: query
            }).then(res => {
                if (!res.data.url) return
                window.location.href = this.define.comUrl + res.data.url
                this.$refs.ExportBox.visible = false
                this.exportBoxVisible = false
            })
        },
        search() {
            this.listQuery = {
                currentPage: 1,
                pageSize: 20,

                sort: "desc",
                sord: "Id",
            }
            this.initData()
        },
        refresh(isrRefresh) {
            this.formVisible = false
            if (isrRefresh) this.reset()
        },
        reset() {
            for (let key in this.query) {
                this.query[key] = undefined
            }
            this.listQuery = {
                currentPage: 1,
                pageSize: 20,

                sort: "desc",
                sord: "Id",
            }
            this.initData()
        }
    }
}
</script>